
function submitArticle() {
    $('#SubmitTips').modal('hide');
    $('#SubmitResultModalLabel').html("正在投稿中...");
    $('#SubmitResultIcon').addClass('fa-circle-notch').removeClass('fa-window-close').removeClass('fa-calendar-check');
    $('#SubmitResultModal').modal();
    $('#submitResultButton').removeAttr('data-dismiss');
    console.log("准备提交form表单");
    let form = $('#submission_form');
    $.ajax({
        url: "/submission/article",
        type: "get",
        dataType: "json",
        data: form.serialize(),
        success: function (result) {
            if(result["submitResult"]){
                submitSuccess();
                console.log("提交成功");
            }
            else{
                submitFailed(result);
                console.log("包含敏感词，提交失败");
            }
        },
        error: function(request) {
            $('#SubmitResultIcon').removeClass('fa-circle-notch').addClass('fa-window-close');
            $('#SubmitResultModalLabel').html("网络连接失败！");
            $('#submitResultButton').attr('href',"#").attr('data-dismiss','modal');
            console.log("连接失败");
        }
    })
}

function submitSuccess() {
    // 更新提交成功窗口
    $('#submitResultButton').attr('href','/reader');
    $('#SubmitResultModalLabel').html("上传成功");
    $('#SubmitResultIcon').removeClass('fa-circle-notch').addClass('fa-calendar-check');
}
function submitFailed(result){
    let filterString = result["filterString"];
    $('#sensitiveWordList').html(filterString);
    $('#submitFailedModal').modal();
    $('#submitResultButton').attr('href',"#");
}

function hideAllSubmitWindows(){
    $('#SubmitResultModal').modal('hide');
}